<template>
  <div class="loading-container">
    <div v-if="loading" class="loading-overlay">
      <!-- <div class="spinner"> -->
        <dv-loading>
          <div color-white>Loading...</div>
        </dv-loading>
      <!-- </div> -->
    </div>

    <div v-else>
      <!-- 正常内容 -->
      <RouterView />
    </div>
  </div>
</template>

<script setup lang="ts">
import { RouterView } from "vue-router";
import { ref } from "vue";

const loading = ref(true); // 默认为 true，显示加载动画

// 模拟加载数据的延迟
setTimeout(() => {
  loading.value = false; // 加载完成后隐藏加载动画
}, 2000);
</script>

<style scoped>
.loading-container {
  position: relative;
  height: 100vh; /* 让容器占满整个视口 */
  display: flex;
  justify-content: center;
  align-items: center;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, #00183e, #002d5b);
  display: flex;
  justify-content: center;
  align-items: center;
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: #09f;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-right: 10px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
</style>